1.0 Error
After updating the website to a new version of Drupal 7, the following error was printed on the web pages.
Notice: Trying to get property of non-object in block_block_view() (line 247 of modules/block/block.module).
2.0 Resolution
The error was resolved by the following steps.
2.1 Turn off block caching
From the Administration menu, Select Configuration –> Development –> Performance. Under CACHING un-check Cache blocks.
2.2 Modify block.module file
Go to the modules/block directory under the website root directory. Open the file block.module. Find the following code near line 247.
/** * Implements hook_block_view(). * * Generates the administrator-defined blocks for display. */ function block_block_view($delta = '') { $block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject(); $data['subject'] = NULL; $data['content'] = check_markup($block->body, $block->format, '', TRUE); return $data; }
Change the above code to,
/** * Implements hook_block_view(). * * Generates the administrator-defined blocks for display. */ function block_block_view($delta = '') { $block = db_query('SELECT body, format FROM {block_custom} WHERE bid = :bid', array(':bid' => $delta))->fetchObject(); if (!empty($block)) { $data['subject'] = NULL; $data['content'] = check_markup($block->body, $block->format, '', TRUE); return $data; } }